#include <stdio.h>
#include <stdarg.h>

//printf 应该先解析出每个%后的字符，选择相应类型
//再调用 va_list 来打印相应参数 
//可以用switch来实现

int sumInt(int, ...);


int main(){

    printf("the sum is %d\n", sumInt(2,3,3));
    printf("===============================================\n");
    printf("the sum is %d\n", sumInt(5,3,3,4,5,6));
    printf("===============================================\n");

    return 0;
}

int sumInt(int n, ...){
    int sum = 0;
    int i = n;

    va_list ap;
    va_start(ap, n);

    while(i > 0){
        sum += va_arg(ap, int);
        i--;
    }

    va_end(ap);

    return sum;
}
